package com.ali.gts.servlet.service.impl;


import com.ali.gts.servlet.dao.UserDao;
import com.ali.gts.servlet.dao.impl.UserDaoImpl;
import com.ali.gts.servlet.domain.User;
import com.ali.gts.servlet.service.UserService;
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIConversion;

/*
 * 处理用户相关业务的实现类
 */
public class UserServiceImpl implements UserService {

	private UserDao userDao = new UserDaoImpl();
	
	@Override
	public boolean   regist(User user) {
		
		User dbUser = userDao.getByName(user.getUsername());
		if(dbUser==null) {
			userDao.insert(user);
			return true;
		}
		return false;
		
	}

	@Override
	public User login(String username, String password) {
		System.out.println("正在登陆中");

		return userDao.getByNameAndPwd(username, password);
		//return true;
	}

	@Override
	public boolean existUsername(String username) {
		User user = userDao.getByName(username);

		if(user == null){
			return false;
		}
		return true;
	}

}
